<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加商品</title>
	 <link rel="stylesheet" href="__PUBLIC__/css/index.css">
  <script src="__PUBLIC__/js/jquery-1.7.2.min.js"></script>
  <script src="__PUBLIC__/js/js.js"></script>
            <style>     
           #add{
                color:red;
                cursor:pointer;
                height:100px;
           }
           .bac{
               background:#F3F3F3;
           }
           #close{
            cursor:pointer;
            color:red;
           }
           .img{
              float: left;
              margin-left:10px;
              margin-bottom:10px;
              position: relative;
           }
           .wrapImg{
              overflow: hidden;
           }
           .close{
              position: absolute;
              top:5px;
              right:5px;
              color:red;
              cursor:pointer;
              font-weight: 700;
              display: block;

           }
             .guige{
            cursor:pointer;
           }

      </style>
      <js file="__CONTROL_TPL__/js/js.js"/>
</head>
<body>
	<form method="post" enctype="multipart/form-data" class="form">
		<input type="hidden" name="gid" value="{$hd.get.gid}">
            <input type="hidden" name="cid" value="{$hd.get.cid}">
		<div class="wrap">
			<div class="menu_list">
				<ul>
				<li>
					<a href="{|U:index}">商品列表</a>
				</li>
				<li>
					<a href="" class="action">添加商品</a>
				</li>
			        </ul>
			</div>

			<div class="tab">
				<ul>
					<li class="btn1 w100 action">
				        基本信息
					</li>
					<li class="btn1 w100">
						详细内容
					</li>
					<li class="btn1 w100">
						图片
					</li>
				</ul>

			<div class="tab-content">	
				<!-- 基本信息 -->
                                    	<table class="table2" >
                                    		<tr>
                                    			<th class="w150">名称</th>
                                    			<td >
                                    				<input type="text" name="gname" id="" class="w300" value="{$data.gname}">
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">属性</th>
                                    			<td >
                                    				<label>置顶<input type="checkbox" name="flag[]" id="" value="置顶" <if value="strstr($data[flag],置顶)">checked=""</if>></label>
                                    				<label>推荐<input type="checkbox" name="flag[]" id="" value="推荐" <if value="strstr($data[flag],推荐)">checked=""</if>></label>
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">栏目</th>
                                    		      <td>
                                                   <list from="$category" name="cate">
                                                      <if value="{$cate.cid} eq {$data.cid}">{$cate._name}</if>
                                                   </list>  
                                              </td>
                                    		 </tr>
                                         <!-- 商品普通属性 -->
                                          <tr>
                                              <th class="w150">商品属性类型</th>
                                                <td>
                                                  <table>
                                                   <list from="$GoodsAttrData" name="GoodsAttr">
                                                    <tr>
                                                      <th>{$GoodsAttr.attr_name}</th>
                                                      <td>{$GoodsAttr.html}</td>
                                                    </tr>
                                                   </list>
                                                    </table>
                                                </td>
                                            </tr>
                                            <!-- 商品属性结束 -->

                                            <!-- 商品规格 -->
                                             <tr>
                                              <th class="w150">商品属性规格</th>
                                                <td>
                                                  <table>
                                                    <tr align="center">
                                                      <list from="$GoodSpecData[0][name]" name="GoodSpec">
                                                         <td>{$GoodSpec.name}</td>
                                                      </list>
                                                      <td>库存</td>
                                                      <td>价格</td>
                                                      <td>货号</td>
                                                      <td>操作</td>
                                                    </tr>
                                                  <tbody>
                                                       <list from="$GoodSpecData" name="GoodSpec">
                                                        <tr class="one">
                                                           <list from="{$GoodSpec.html}" name="Spec">
                                                             <td>{$Spec.spec}</td>
                                                           </list>
                                                       <td>
                                                        <input type="text" value="{$GoodSpec.stock}" name="stock[]" id="">
                                                      </td>
                                                      <td>
                                                        <input type="text" value="{$GoodSpec.price}" name="price[]" id="">
                                                      </td>
                                                      <td>
                                                        <input type="text" value="{$GoodSpec[goods_sn]}" name="goods_sn[]" id="">
                                                      </td>
                                                      <td align="center">
                                                         <span class="guige" onclick="addSpec(this)" >加（+）</span>
                                                      </td>
                                                    </tr>
                                                    </list>
                                                   
                                                  </tbody>
                                                
                                                    </table>
                                                </td>
                                            </tr>
                                      <!-- 商品规格结束 -->
                                                 <tr>
                                                      <th class="w150">品牌</th>
                                                      <td >
                                                            <select name="brandid" id="">
                                                                  <option value="">==请选择==</option>
                                                                      <list from="$brand" name="bra" >
                                                                        <option value="{$bra.bid}" <if value="{$bra.bid} eq {$data.brandid}">selected=""</if>>{$bra.bname}</option>
                                                                      </list>
                                                            </select>
                                                      </td>
                                                 </tr>
                                               
                                    		  <tr>
                                    		 	<th class="w150">关键字</th>
                                    		          <td>
                                    		          	<input type="text" value="{$data.keywords}" name="keywords" id="" class="w300">
                                    		          </td>
                                    		 </tr>
                                    		   <tr>
                                    		 	<th class="w150">描述</th>
                                    		          <td>
                                    		          	<textarea name="description" id="" cols="30" rows="10" class="w400 h100">{$data.description}</textarea>
                                    		          </td>
                                    		 </tr>
                                    	</table>
                                </div>
                                    <!-- 详细信息 -->
                                    <div class="tab-content" >
                                    	<table class="table2" >
                                    		<tr>
                                    			<th class="w150">内容</th>
                                    			<td >
                                    				<ueditor name="body" content="{$data.body}"/>
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">服务</th>
                                    			<td >
                                    				<input type="text" value="{$data.service}" name="service" id="" class="w300">
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">查看次数</th>
                                    			<td >
                                    				<input type="text" value="{$data.click}" name="click" id="" class="w300">
                                    			</td>
                                    		</tr>
                                                  <tr>
                                                                  <th class="w150">更新时间</th>
                                                                  <td >
                                                                        <input type="text" name="addtime" id="addtime" class="w300" readonly="readonly"   value="{|date:'Y/m/d h:i:s'}">
                                                                  </td>
                                                      </tr>
                                    	</table>
                                    </div>
                                    <div class='tab-content'>
                                    	<table class="table2">
                                    		<tr>
                                    			<th>首页图</th>
                                    			<td>
         
                                    				<input type="file" name="index_pic" id="" >
                                    				<img src="__ROOT__/{$data.index_pic}" alt="" class="w50 h50 m10">
                                    				<input type="hidden" name="index_pic" value="{$data.index_pic}">
                                    				
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th>列表图</th>
                                    			<td>
                                    				<input type="file" name="list_pic" id="">
                                    				<img src="__ROOT__/{$data.list_pic}" alt="" class="w50 h50 m10">
                                    				<input type="hidden" name="list_pic" value="{$data.list_pic}">
                                    			</td>
                                    		</tr>
                                                            <tr>
                                                                  <th>内容图</th>
                                                                  <td id="td" >
                                                                        <div class="wrapImg">
                                                                              <list from="$pic" name="p">
                                                                                    <div class="img">
                                                                                <img src="__ROOT__/{$p.medium}"  class="w100 h100">
                                                                                <span class="close" id="{$p.pic_id}">X</span>
                                                                                    </div>

                                                                              </list>
                                                                        </div>

                                                                        <div class="content">
                                                                              <input type="file" name="pic[]" id="" class="w150">
                                                                           <span id="add" >增加（+）</span>
                                                                        </div>
                                                                  </td>
                                                            </tr>
                                    	</table>
                                    </div>
	</div>
		<!-- 底部确定按钮 -->
	<div class="position-bottom">
                     <input type="submit" value="确定" class="btn">
                    </div>
	</form>
</body>
<script>

      $("#addtime").calendar({format: 'yyyy/MM/dd HH:mm:ss'});
      var input="<div style='margin-top:10px' class='content'><input type='file' name='pic[]' id= class='w150' class='w150' ><span style='color:red;margin-left:5px;cursor:pointer'  class='del1'>减少（-）<span></div>";
      $("#add").click(function(){
            $("#td").append(input);
      })
      $(".del1").live("click",function(){
            $(this).parent().remove();
      })
      $(".content").live("hover",function(){
            $(this).addClass('bac').siblings('.content').removeClass('bac');
      })

</script>
<script>
      $(function(){
      $(".close").click(function(){
            var pic_id=$(this).attr("id");
            var _this=$(this);
            $.post("?m=delContentPic",{pic_id:pic_id},function(data){
                   if(data==1){
                        $(_this).parent().remove();
                   }else{
                       alert("删除失败");
                   }
            })
      })
})

//改变规格添加按钮的样式（除了第一个是加，其余的是减）
$(".guige:gt(0)").text("减（-）");
$(".guige:gt(0)").removeAttr("onclick");
</script>
</html>








